<?php
	$css_list[0]['url'][] = './tpl/css/general.css';
	$css_list[0]['url'][] = './tpl/css/book.css';
	$js_list[0] = './tpl/js/book.js';
	$js_list[1] = './public/js/jquery.masonry.js';
?>
<!--{template inc/header}-->
<div id="body" class="container_16">
	<div class="imagewall_sort" style="height:40px;">
	</div>
	<div id="imagewall_container" class="imagewall">
		<div class="i_w_f o u_profile">
			<div class="b_u_hd"></div>
			<div class="b_u_bd">
				<div class="up_info">
					<a class="uavatar" href="{u u/index uid=$home_uid}"><img src="{avatar $home_user['avatar'] b}" width="100" height="100" /></a>
					<a class="name gc" href="{u u/index uid=$home_uid}">{$home_user['user_name']}</a>
					<!--{if $is_show_follow}-->
					<a href="javascript:;" class="add_fo" onclick="$.User_Follow($home_uid,this,UpdateUserFollow);"></a>
					<!--{elseif $home_uid != $_FANWE['uid']}-->
					<a class="fo_st"></a>
					<!--{/if}-->
				</div>
				<!--{if !empty($reside_province) || !empty($home_user['introduce'])}-->
				<p class="ml5">
					<div class="up_address">
						<!--{if !empty($reside_province)}-->
						{$reside_province} {$reside_city}
						<!--{/if}-->
						<p>{$home_user['introduce']}</p>
					</div>
				</p>
				<!--{/if}-->
				<div class="up_userhome">
					<a href="{u u/index uid=$home_uid}" target="_blank" class="gohome">去{$_FANWE['home_user_names']['short']}的家</a>
					<a href="{u u/topic uid=$home_uid}" target="_blank">主题</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="{u u/photo uid=$home_uid}" target="_blank">相册</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="{u u/bao uid=$home_uid}" target="_blank">宝贝</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="{u u/fav uid=$home_uid}" target="_blank">喜欢</a>
				</div>
				<div class="up_title">
					她关注的热点：
					<ul class="nt_list">
						{loop $focus_tags $r $tag}
							<li><a target="_blank" href="{echo FU("book/shopping",array("tag"=>urlencode($tag['tag_name'])))}">$tag['tag_name']</a><i></i></li>
						{/loop}
					</ul>
				</div>
			</div>
			<div class="b_u_ft"></div>
		</div>
		<!--{loop $share_list $share}-->
		<div class="i_w_f" id="share_item_{$share['share_id']}">
			<div class="hd"></div>
			<div class="bd">
				<ul class="pic">
					<!--{loop $share['imgs'] $share_img}-->
					<!--{if $share_img['type'] == 'g'}-->
					<li>
						<a style="width:200px;" href="{$share_img['url']}" target="_blank">
							<img class="book_img lazyload" original="{getimg $share_img['img'] 200 999}" width=200 src="./tpl/images/lazyload.gif" oldWidth="{$share_img['img_width']}" oldHeight="{$share_img['img_height']}"/>
						</a>
						<span class="p"><span>{$share_img['price_format']}</span><i></i></span>
						<a class="add_to_album_btn" href="javascript:;" style="display: none;" onclick="$.Show_Rel_Album($share_img['id'],'goods');"></a>
					</li>
					<!--{else}-->
					<li>
						<a style="width:200px;" href="{$share_img['url']}" target="_blank">
							<img class="book_img lazyload" original="{getimg $share_img['img'] 200 999}" width=200 src="./tpl/images/lazyload.gif" oldWidth="{$share_img['img_width']}" oldHeight="{$share_img['img_height']}"/>
						</a>
						<a class="add_to_album_btn" href="javascript:;" style="display: none;" onclick="$.Show_Rel_Album($share_img['id'],'photo');"></a>
					</li>
					<!--{/if}-->
					<!--{/loop}-->
				</ul>
				<div class="favorite">
					<a href="javascript:;" class="favaImg" onclick="$.Fav_Share({$share['share_id']},this,32,'#share_item_{$share['share_id']}');"></a>
					<div class="favDiv"><a target="_blank" class="favCount SHARE_FAV_COUNT" href="{$share['url']}"  >$share['collect_count']</a></div>
					<a target="_blank" href="{$share['url']}" class="creply"><b>{$share['comment_count']}</b>评论</a>
				</div>
			</div>
			<div class="who_share">
				<div class="ws_bd clearfix">
					<!--{getuser $share['uid'] 0 's,24' ',icard avt fl lazyload'}-->
					<p class="fr clearfix">
						<span class="fl"><!--{getuser $share['uid'] 0 '' 'n icard'}--></span>
						<span class="t fr">{$share['time']}</span>
						<span class="tkinfo clearfix">
							{cutstr $share['content'] 200}
						</span>
					</p>
				</div>
				<div class="ws_ft"></div>
			</div>
		</div>
		<!--{/loop}-->
	</div>
	<!--{if $pager['page_count'] > 1}-->
	<div class="pagination pd_tb" id="pageBox"> 
	     <!--{subtemplate inc/pages}-->
	</div>
	<!--{/if}-->
	<div class="clear"></div>
</div>
<div id="pbLoading" style="background:url(./tpl/images/loading.gif) no-repeat center center;height:52px; display:none;"></div>
<div class="hide">
<!--{if $pager['page_count'] > 0}-->
<!--{loop $pb_list $url}-->
<a href="{$url}">{$url}</a>
<!--{/loop}-->
<!--{/if}-->
</div>
<script type="text/javascript">
var rowHtml = '<div class="i_w_f i_w_f_f empty_row"><div class="hd"></div><div class="bd" style="height:#HEIGHT#px;"></div><div class="ft"></div></div>';
var pbUrl = "{$pb_url}";
var imgWidth = 200;
var pbMaxIndex = {$_FANWE['setting']['share_pb_load_count']};

jQuery(function(){
	$(".book_img").each(function(){
		var oldWidth = parseInt(this.getAttribute("oldWidth"));
		var oldHeight = parseInt(this.getAttribute("oldHeight"));
		if(isNaN(oldWidth) || isNaN(oldHeight) || oldWidth == 0 || oldHeight == 0)
		{
			this.height = 0;
		}
		else
		{
			var scale = imgWidth / oldWidth;
			this.height = oldHeight * scale;
		}
	});

	$('#imagewall_container').css({"height":"auto","background":"none"});
	$('.i_w_f').css("visibility","visible");
	
	$('#imagewall_container').masonry({
		itemSelector: '.i_w_f',
		isAnimated:true,
		gutterWidth:15,
		gutterHeight:8,
		columnWidth:225
	});

	<!--{if $pager['page_count'] > 0}-->
	createPBScroll(pbUrl,appendShareItem,pbLoadingFun,2,pbMaxIndex,300);
	<!--{/if}-->
});

function appendBottomItem()
{
	var lefts = new Object();
	var colTotal = 4;
	$(".i_w_f").each(function(i){
		if($(this).position().top == 0)
		{
			lefts['l'+$(this).position().left] = $(this);
		}
		else
		{
			if(lefts['l'+$(this).position().left].position().top <  $(this).position().top)
				lefts['l'+$(this).position().left] = $(this);
		}
	});
	
	var cols = 0;
	var maxLeft = '';
	var currentSize = 0;
	var maxSize = 0;
	for(var left in lefts)
	{
		cols++;
		currentSize = lefts[left].position().top + lefts[left].height();
		if(currentSize > maxSize)
		{
			maxLeft = left;
			maxSize = currentSize;
		}
	}
	
	var htmlArray = new Array();
	var htmlObjs = new Object();
	html = '';
	for(var left in lefts)
	{
		currentSize = lefts[left].position().top + lefts[left].height();
		if(currentSize < maxSize)
		{
			htmlObjs['h'+(maxSize - currentSize)] = rowHtml.replace("#HEIGHT#",maxSize - currentSize - 30);
			htmlArray.push(maxSize - currentSize);
		}
	}

	var newArray = htmlArray.sort(function(a,b){
		if(a > b)
			return -1;
		else if(a < b)
			return 1;
		else
			return 0;
	});
	
	for(var h=0;h<newArray.length;h++)
	{
		html += htmlObjs['h'+newArray[h]];
	}

	if(colTotal > cols)
	{
		for(var i=0; i< (colTotal - cols);i++)
		{
			html = rowHtml.replace("#HEIGHT#",maxSize - 22) + html;
		}
	}
	html = $('<div>' + html + '</div>').find('.i_w_f');
	$('#imagewall_container').append(html).masonry('appended',html,true);
}

function appendShareItem(result,index)
{
	html = '<div>' + result + '</div>';
    html = $(html).find('.i_w_f');
	$(".book_img",html).each(function(){
		var oldWidth = parseInt(this.getAttribute("oldWidth"));
		var oldHeight = parseInt(this.getAttribute("oldHeight"));
		if(isNaN(oldWidth) || isNaN(oldHeight) || oldWidth == 0 || oldHeight == 0)
		{
			this.height = 0;
		}
		else
		{
			var scale = imgWidth / oldWidth;
			this.height = oldHeight * scale;
		}
	});
	$('#imagewall_container').append(html).masonry('appended',html,true,function(){
		if(index >= pbMaxIndex || result == '')
		{
			$("#pageBox").show();
			var fun = function(){
				appendBottomItem();
			}
			setTimeout(fun,1000);
		}
	});
}

function pbLoadingFun(bln)
{
	if(bln)
		$("#pbLoading").show();
	else
		$("#pbLoading").hide();
}

function UpdateUserFollow(obj,result)
{
	if(result.status == 1)
	{
		$(obj).before('<a class="fo_st"></a>');
		$(obj).remove();
	}
}
</script>
<!--{template inc/footer}-->